//
//  BkMessageOrderView.m
//  TuDianEducation
//
//  Created by lixinkeji on 2021/2/1.
//  Copyright © 2021 zhangbenchao. All rights reserved.
//

#import "BkMessageOrderView.h"
@interface BkMessageOrderView()
@property (nonatomic,strong) UIImageView *headerImgView;
@property (nonatomic,strong) UILabel *bkNameLabel;
@property (nonatomic,strong) UILabel *moneyLabel;
@property (nonatomic,strong) UILabel *sevendaysLabel;
@property (nonatomic,strong) UILabel *amountLabel;
@end
@implementation BkMessageOrderView

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.frame = CGRectMake(0, 0, TSScreenWidth, TSScaleW(200));
        [self addSubview:self.headerImgView];
        [self addSubview:self.bkNameLabel];
        [self addSubview:self.moneyLabel];
        [self addSubview:self.sevendaysLabel];
        [self addSubview:self.amountLabel];
        self.height = self.amountLabel.bottom + TSScaleW(15);
    }
    return self;
}
-(UIImageView *)headerImgView{
    if (!_headerImgView) {
        _headerImgView = [[UIImageView alloc]initWithFrame:CGRectMake(TSScaleW(15), TSScaleW(15) , TSScaleW(47), TSScaleW(63))];
        _headerImgView.backgroundColor = kGrayTxtColor;

    }
    return _headerImgView;
}
-(UILabel *)bkNameLabel{
    if (!_bkNameLabel) {
        _bkNameLabel = [TSWLTools allocLabel:@"初中数学运算大法" font:systemFont(TSScaleW(14)) textColor:kMainTxtColor frame:CGRectMake(_headerImgView.right + TSScaleW(10),   TSScaleW(18), TSScaleW(210), TSScaleW(14)) textAlignment:(NSTextAlignmentLeft)];
        //_bkNameLabel.numberOfLines = 0;
    }
    return _bkNameLabel;
}
-(UILabel *)moneyLabel{
    if (!_moneyLabel) {
        _moneyLabel = [TSWLTools allocLabel:@"￥999.00" font:systemFont(TSScaleW(12)) textColor:kMainTxtColor frame:CGRectMake(_headerImgView.right + TSScaleW(10), _bkNameLabel.top, TSScaleW(260), TSScaleW(15)) textAlignment:(NSTextAlignmentRight)];
        NSString *string = _moneyLabel.text;
        NSMutableAttributedString *atts = [[NSMutableAttributedString alloc] initWithString:string];
        [atts setAttributes:@{NSFontAttributeName:systemBoldFont(TSScaleW(15))} range:NSMakeRange(1,  string.length - 4)];
        _moneyLabel.attributedText = atts;
    }
    return _moneyLabel;
}
-(UILabel *)sevendaysLabel{
    if (!_sevendaysLabel) {
        _sevendaysLabel = [TSWLTools allocLabel:@"7天无理由退换" font:systemFont(10) textColor:UIColorFromRGB(0xD95F35) frame:CGRectMake(_bkNameLabel.left, TSScaleW(9) + _bkNameLabel.bottom, TSScaleW(80), TSScaleW(15)) textAlignment:(NSTextAlignmentCenter)];
        _sevendaysLabel.backgroundColor = UIColorFromRGB(0xFFF1F1);
        _sevendaysLabel.cornerRadius = _sevendaysLabel.height/2.f;
        
    }
    return _sevendaysLabel;
}
-(UILabel *)amountLabel{
    if (!_amountLabel) {
        _amountLabel = [TSWLTools allocLabel:@"x1" font:systemFont(12) textColor:kGrayTxtColor frame:CGRectMake(_moneyLabel.left, TSScaleW(37) + _moneyLabel.bottom, _moneyLabel.width , TSScaleW(12)) textAlignment:(NSTextAlignmentRight)];
    }
    return _amountLabel;
}
/**
 {
            "odid":""//订单详情id
            "gid":""//商品id
            "gname":""//商品名称
            "gimage":""//商品图片
            "gprice":""//商品价格
            "gnum":""//商品数量
          }
 */
-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    [_headerImgView sd_setImageWithURL:[NSURL URLWithString:_dataDic[@"gimage"]]];
    _bkNameLabel.text = _dataDic[@"gname"];
//    _moneyLabel.text = [NSString stringWithFormat:@"￥%@",_dataDic[@"gprice"]];
//    NSString *string = _moneyLabel.text;
//    NSMutableAttributedString *atts = [[NSMutableAttributedString alloc] initWithString:string];
//    [atts setAttributes:@{NSFontAttributeName:systemBoldFont(TSScaleW(15))} range:NSMakeRange(1,  string.length - 4)];
//    _moneyLabel.attributedText = atts;
    
        _moneyLabel.text = [NSString stringWithFormat:@"%@",_dataDic[@"gprice"]];
        NSString *string = _moneyLabel.text;
        NSMutableAttributedString *atts = [[NSMutableAttributedString alloc] initWithString:string];
        [atts setAttributes:@{NSFontAttributeName:systemBoldFont(TSScaleW(15))} range:NSMakeRange(0,  string.length - 3)];
        _moneyLabel.attributedText = atts;
   
    _amountLabel.text = [NSString stringWithFormat:@"x%@",_dataDic[@"gnum"]];
}
@end
